package jzqb.common;

import java.util.*;

public class ContainUtils {

    // resource 12;23;34;123;34 中是否包含target 12的方法
    public static Boolean KBContains(String resource, String target) {
        if ("".equals(resource) || resource == null) {
            return false;
        }
        Boolean res = false;
        String[] srtArr = resource.split(";");
        for (String s : srtArr) {
            if (s.equals(target)) {
                res = true;
                break;
            }
        }
        return res;
    }

    // resource 12;23;34;123;34 中是否包含target 12  返回的是 23;34;123;34
    public static String KBDelete(String resource, String target) {
        String[] strArr = resource.split(";");
        List<String> strList= Arrays.asList(strArr);
        List<String> arrList = new ArrayList(strList);
        Iterator iter = arrList.iterator();
        while (iter.hasNext()) {
            if (iter.next().equals(target)) {
                iter.remove();
            }
        }
        StringBuffer stringBuffer = new StringBuffer();
        for (String s : arrList) {
           stringBuffer.append(s).append(";");
        }
       return stringBuffer.toString();
    }
}
